<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	template="/pages/templates/templateMain.xhtml">

	<ui:param name="browser_tab_title" value="Bundle Admin" />
	<ui:param name="page_title" value="Bundle Admin" />

	<ui:define name="content">
		<p:panel id="repositorySelectionPanel">
			<f:facet name="header">
				<h:outputText value="Repository Selection" />
			</f:facet>

			<h:form styleClass="repository-info">
				<h:panelGrid columns="3">

					<h:panelGroup styleClass="repository-info-block">
						<h:outputLabel value="Active repository: "
							for="repositorySelector" />
						<h:selectOneMenu value="#{selectedRepository}"
							id="repositorySelector">
							<s:selectItems var="item" value="#{repositoryList}"
								label="#{item.name}" noSelectionLabel="Select repository"
								id="repositoryList" />
							<a4j:support event="onchange"
								action="#{bundleListBean.getBundleList}"
								reRender="dataTablePanel, repositorySelectionPanel" />
							<s:convertEntity />
						</h:selectOneMenu>
					</h:panelGroup>

					<c:if test="#{selectedRepository ne null}">
						<h:panelGroup styleClass="repository-info-block">
							<h:outputLabel value="Description: " for="descriptionText" />
							<h:outputText value="#{selectedRepository.description}"
								id="descriptionText" />
						</h:panelGroup>

						<h:panelGroup styleClass="repository-info-block">
							<h:outputLabel value="URL: " />
							<a href="#{selectedRepository.url}"><h:outputText
								value="#{selectedRepository.url}" /></a>
						</h:panelGroup>
					</c:if>
				</h:panelGrid>
			</h:form>
		</p:panel>

		<p:panel id="dataTablePanel" style="margin-top: 30px">
			<h:form>
				<p:dataTable id="bundleDataTable" value="#{bundleList}"
					var="_bundle" emptyMessage="No item to display" paginator="true"
					paginatorPosition="top" rows="20">

					<p:column filterBy="#{_bundle.bundleData.symbolicName}">
						<f:facet name="header">
							<h:outputText value="Symbolic name" />
						</f:facet>
						<h:outputText value="#{_bundle.bundleData.symbolicName}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Presentation name" />
						</f:facet>
						<h:outputText value="#{_bundle.bundleData.presentationName}" />
					</p:column>

					<p:column filterBy="#{_bundle.bundleData.version}"
						filterStyle="width: 50px" styleClass="centered">
						<f:facet name="header">
							<h:outputText value="Version" />
						</f:facet>
						<h:outputText value="#{_bundle.bundleData.version}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Details" />
						</f:facet>

						<h:commandButton id="detailsButton" image="/images/search-32.png"
							value="Details" action="#{bundleListBean.bundleDetails}">
							<f:setPropertyActionListener value="#{_bundle}"
								target="#{bundle}" />
						</h:commandButton>
						<p:tooltip for="detailsButton"
							value="Basic data, capabilities, requirements" />
					</p:column>
				</p:dataTable>
				<h:commandButton value="Test" action="details" />
			</h:form>
		</p:panel>

		<!--		<p:dialog widgetVar="manifestModal" modal="true" header="Manifest.mf"-->
		<!--			draggable="false" position="center" resizable="false" width="700"-->
		<!--			height="500">-->
		<!--			<h:panelGroup id="manifestText">-->
		<!--				<p>#{bundleData.manifest}</p>-->
		<!--			</h:panelGroup>-->
		<!--		</p:dialog>-->
		<!---->
		<!--		<p:dialog widgetVar="detailsModal" modal="true"-->
		<!--			header="Bundle details" draggable="false" position="center"-->
		<!--			resizable="false" width="700" height="500">-->
		<!--			<h:panelGroup id="details">-->
		<!--				<ui:include src="/pages/bundle/bundleDetails.xhtml" />-->
		<!--			</h:panelGroup>-->
		<!--		</p:dialog>-->
	</ui:define>

</ui:composition>